home *** CD-ROM | disk | FTP | other *** search
- ; definition of add1
- (defun add1 (x) (+ x 1))
-
- ; definition of sub1
- (defun sub1 (x) (- x 1))
-
- ; definition of double
- (defun double (x) (* x x))
-
- ; DEFINITION OF LESSP
- (defun lessp (x y)
- (! (>= x y)))
-
- ;DEFINITION OF GRTP
- (defun grtp (x y)
- (! (<= x y)))
-
- ; DEFINITION OF MINUS
- (defun minus (x)
- (* x -1))
-
- ; DEFINITION OF ABS (ABSOLUTE VALUE)
- (defun abs (x)
- (if (lessp x 0) (print (minus x)) (print x)))
-
- ;DEFINITION OF COMPARE
- (defun compare (x y)
- (cond ((equal x y) 'numbers-are-the-same)
- ((lessp x y) 'first-is-smaller)
- ((grtp x y) 'first-is-bigger)))
-
- ; DEFINITION OF COMPUTE
- (defun compute (op x y)
- (cond ((equal op 'add) (+ x y))
- ((equal op 'subtract) (- x y))
- ((equal op 'multiply) (* x y))
- ((equal op 'divide) (/ x y))
- (t '(I do not know how to do that))))
-
-
-
-
-
-
-
-
-
-
-
- (* x y))
-